package com.learn;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * ApplicationContextInitializer：容器refreshed之前的回调
 * 使用步骤：
 *  1.写一个类实现ApplicationContextInitializer接口
 *  2.注册ApplicationContextInitializer
 *  	1.SpringApplication.addInitializers
 *  	2.使用配置:context.initializer.classes=com.learn.MyApplicationContextInitializer ,可以指定多个，逗号分割
 *  	3.通过/springboot-children/src/main/resources/META-INF/spring.factories
 *  		配置org.springframework.context.ApplicationContextInitializer=com.learn.EchoApplicationContextInitializer
 *  		这种方法可以通过引用别的项目来实现
 *  
 *  
 *  CommandLineRunner ,ApplicationRunner 接口是容器启动成功后的最后一步回调
 *  使用步骤：
 * 	1.写一个类实现CommandLineRunner接口,可以配置多个，可以使用@order注解控制执行的顺序
 * 	2.把类加入到spring容器中
 * 
 * CommandLineRunner ,ApplicationRunner 区别
 * 	CommandLineRunner是原始参数
 *	ApplicationRunner的参数是ApplicationArguments对象，是对原始参数的封装
 *  		
 * @author Romanceling
 *
 */
@SpringBootApplication
public class App 
{
    public static void main( String[] args ){
    	SpringApplication app = new SpringApplication(App.class);
    	//app.addInitializers(new MyApplicationContextInitializer());
        ConfigurableApplicationContext context = app.run("aa","bb");
        context.close();
    }
}
